feat: AgentCreateSchema accepts workspace / filesystemScope / fileAccessPolicy - #96
Closed
siglimumuni wants to merge 1 commit into
Closed
Conversation
…teSchema These three fields are defined on the Agent TYPE and consumed at runtime (filesystemScope by file.ts, fileAccessPolicy by context.ts, workspace by various callers) but were missing from the Zod validation schema. As a result, PUT /api/agents/:id silently dropped them from the body — they never reached storage, leaving the corresponding runtime behaviors unreachable via the public API. Concretely: setting workspace='/custom/dir' + filesystemScope='workspace' + fileAccessPolicy.blockedPaths via PUT /api/agents/:id appeared to succeed (200 OK with the prior agent record back), but a follow-up GET showed all three fields still null/unset. The only way to set them was to write directly to the agents table. Adds them to AgentCreateSchema (which AgentUpdateSchema inherits via .partial()), matching the types in src/types/agent.ts. No runtime behavior change beyond letting these fields round-trip through the API. Files: - src/lib/validation/schemas.ts
Member
|
Cherry-picked and shipped in v1.9.33 with route-level persistence coverage for the workspace filesystem settings. Thanks for the fix. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three fields defined on the `Agent` type and consumed at runtime — `workspace`, `filesystemScope`, `fileAccessPolicy` — are missing from the Zod `AgentCreateSchema`. `AgentUpdateSchema` derives from it via `.partial()`, so PUT /api/agents/:id silently drops these fields. The runtime behaviors they control (workspace-scoped file ops, fileAccessPolicy enforcement) are therefore unreachable via the public API.
How I found it
Tried to lock a worker agent down to a dedicated workspace via the API:
```
PUT /api/agents/
{
"workspace": "/Users/foo/agent-workspaces/hugo",
"filesystemScope": "workspace",
"fileAccessPolicy": { "blockedPaths": ["/Users/foo/.ssh/**", ...] }
}
```
Endpoint returned 200 with the agent record. But:
```
GET /api/agents/
→ workspace: null, filesystemScope: null, fileAccessPolicy: null
```
Confirmed in the route handler (app/api/agents/\[id\]/route.ts:20-29): `AgentUpdateSchema.safeParse(raw)` strips unknown keys, then the post-parse filter restricts the body to keys present in `parsed.data` — and the missing schema entries mean those keys are absent from `parsed.data` entirely.
End result: the only way to set these fields is to write directly to the `agents` table.
Fix
Add the three fields to `AgentCreateSchema` matching the types in `src/types/agent.ts`:
No runtime behavior change — just unblocks these fields round-tripping through the API.
Files
Test plan
🤖 Generated with Claude Code